package com.java.tutorials.jdk7.filestore;

import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/GettingFileStoreinformation.htm
 */
public class GettingFileStoreinformation {
    static final long kiloByte = 1024;

    public static void main(String[] args) throws Exception {
        FileSystem fileSystem = FileSystems.getDefault();

        for (FileStore fileStore : fileSystem.getFileStores()) {
            long totalSpace = fileStore.getTotalSpace() / kiloByte;
            long usedSpace = (fileStore.getTotalSpace() - fileStore
                    .getUnallocatedSpace()) / kiloByte;
            long usableSpace = fileStore.getUsableSpace() / kiloByte;
            String name = fileStore.name();
            String type = fileStore.type();
            boolean readOnly = fileStore.isReadOnly();
        }
    }
}
